#!/bin/bash

APPNAME=hello1
containerid=`docker ps -a | grep "$APPNAME" | awk '{print $1 }'`
# echo "containerid $containerid"
if [ -n "$containerid" ] 
then
    docker stop $containerid
    docker rm $containerid
    echo "停止并删除$APPNAME 容器,id为$containerid"
fi

imageid=`docker images|grep "$APPNAME"|awk '{print $3 }'`
# echo "imageid $imageid"
if [ -n "$imageid" ]
then
    docker rmi $imageid
    echo "删除镜像$APPNAME"
fi
